home *** CD-ROM | disk | FTP | other *** search
/ Super Shareware Collection / Super Shareware Collection.iso / os_2 / memsz220.zip / SUPPORT.CPP < prev    next >
Text File  |  1994-02-07  |  31KB  |  830 lines

  1. /***************************************************************** SUPPORT.CC
  2.  *                                                                          *
  3.  *                Presentation Manager Support Functions                    *
  4.  *                                                                          *
  5.  ****************************************************************************/
  6.  
  7. #define INCL_BASE
  8. #define INCL_PM
  9. #include <os2.h>
  10.  
  11. #include <stdarg.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15.  
  16. #include "support.h"
  17. #include "debug.h"
  18.  
  19.  
  20. /****************************************************************************
  21.  *                                        *
  22.  *    Definitions & Declarations                        *
  23.  *                                        *
  24.  ****************************************************************************/
  25.  
  26.   // Local Function Prototypes
  27.  
  28. static ULONG BuildExtendedAttributeItem ( PFEA pFEA, PEADATA Item ) ;
  29.  
  30.  
  31. /****************************************************************************
  32.  *                                                                          *
  33.  *                        Message Dispatcher                                *
  34.  *                                                                          *
  35.  ****************************************************************************/
  36.  
  37. extern MRESULT DispatchMessage
  38. (
  39.   HWND    hwnd,
  40.   USHORT  msg,
  41.   MPARAM  mp1,
  42.   MPARAM  mp2,
  43.   PMETHOD MethodTable,
  44.   USHORT  MethodCount,
  45.   PFNWP   DefaultProcessor
  46. )
  47. {
  48.  /***************************************************************************
  49.   * Local Declarations                                                      *
  50.   ***************************************************************************/
  51.  
  52.   USHORT cNumberLeft ;
  53.   MRESULT mr ;
  54.   PMETHOD pMethod ;
  55.  
  56.  /***************************************************************************
  57.   * Process messages according to object's class method table.              *
  58.   ***************************************************************************/
  59.  
  60.   pMethod = MethodTable ;
  61.   cNumberLeft = MethodCount ;
  62.  
  63.   while ( ( cNumberLeft ) AND ( pMethod->Action != msg ) )
  64.   {
  65.     pMethod ++ ;
  66.     cNumberLeft -- ;
  67.   }
  68.  
  69.   if ( cNumberLeft )
  70.   {
  71.     mr = pMethod->pFunction ( hwnd, msg, mp1, mp2 ) ;
  72.   }
  73.   else
  74.   {
  75.     if ( DefaultProcessor )
  76.       mr = DefaultProcessor ( hwnd, msg, mp1, mp2 ) ;
  77.     else
  78.       mr = 0 ;
  79.   }
  80.  
  81.  /***************************************************************************
  82.   * Return result from message processor.                                   *
  83.   ***************************************************************************/
  84.  
  85.   return ( mr ) ;
  86. }
  87.  
  88. /****************************************************************************
  89.  *                                                                          *
  90.  *                         Add Item to System Menu                          *
  91.  *                                                                          *
  92.  ****************************************************************************/
  93.  
  94. extern VOID AddSysMenuItem ( HWND hwndFrame, MENUITEM *Item, PSZ Text )
  95. {
  96.  /***************************************************************************
  97.   * Local Declarations                                                      *
  98.   ***************************************************************************/
  99.  
  100.   HWND hwndSysMenu ;
  101.   HWND hwndSysSubMenu ;
  102.   USHORT idSysMenu ;
  103.   MENUITEM miSysMenu ;
  104.  
  105.  /***************************************************************************
  106.   * Obtain the system menu window handle.                                   *
  107.   ***************************************************************************/
  108.  
  109.   hwndSysMenu = WinWindowFromID ( hwndFrame, FID_SYSMENU ) ;
  110.  
  111.  /***************************************************************************
  112.   * Get the system menu's base item and its window handle.                  *
  113.   ***************************************************************************/
  114.  
  115.   idSysMenu = SHORT1FROMMR ( WinSendMsg ( hwndSysMenu, MM_ITEMIDFROMPOSITION, NULL, NULL ) ) ;
  116.  
  117.   WinSendMsg ( hwndSysMenu, MM_QUERYITEM,
  118.     MPFROM2SHORT(idSysMenu,FALSE), MPFROMP(&miSysMenu) ) ;
  119.  
  120.   hwndSysSubMenu = miSysMenu.hwndSubMenu ;
  121.  
  122.  /***************************************************************************
  123.   * Add the new item to the system menu's submenu, which is what we see.    *
  124.   ***************************************************************************/
  125.  
  126.   WinSendMsg ( hwndSysSubMenu, MM_INSERTITEM, MPFROMP(Item), MPFROMP(Text) ) ;
  127. }
  128.  
  129. /****************************************************************************
  130.  *                                                                          *
  131.  *                   Add Item to Submenu on System Menu                     *
  132.  *                                                                          *
  133.  ****************************************************************************/
  134.  
  135. extern VOID AddSysSubMenuItem
  136. (
  137.   HWND hwndFrame,
  138.   USHORT SubMenuID,
  139.   MENUITEM *Item,
  140.   PSZ Text
  141. )
  142. {
  143.  /***************************************************************************
  144.   * Local Declarations                                                      *
  145.   ***************************************************************************/
  146.  
  147.   HWND hwndSubMenu ;
  148.   HWND hwndSysMenu ;
  149.   HWND hwndSysSubMenu ;
  150.   USHORT idSysMenu ;
  151.   MENUITEM MenuItem ;
  152.  
  153.  /***************************************************************************
  154.   * Obtain the system menu window handle.                                   *
  155.   ***************************************************************************/
  156.  
  157.   hwndSysMenu = WinWindowFromID ( hwndFrame, FID_SYSMENU ) ;
  158.  
  159.  /***************************************************************************
  160.   * Get the system menu's base item and its window handle.                  *
  161.   ***************************************************************************/
  162.  
  163.   idSysMenu = SHORT1FROMMR ( WinSendMsg ( hwndSysMenu, MM_ITEMIDFROMPOSITION, NULL, NULL ) ) ;
  164.  
  165.   WinSendMsg ( hwndSysMenu, MM_QUERYITEM,
  166.     MPFROM2SHORT(idSysMenu,FALSE), MPFROMP(&MenuItem) ) ;
  167.  
  168.   hwndSysSubMenu = MenuItem.hwndSubMenu ;
  169.  
  170.  /***************************************************************************
  171.   * Get the submenu's base item and its window handle.                      *
  172.   ***************************************************************************/
  173.  
  174.   WinSendMsg ( hwndSysSubMenu, MM_QUERYITEM,
  175.     MPFROM2SHORT ( SubMenuID, TRUE ),
  176.     (MPARAM) &MenuItem ) ;
  177.  
  178.   hwndSubMenu = MenuItem.hwndSubMenu ;
  179.  
  180.  /***************************************************************************
  181.   * Add the new item to the system menu's submenu, which is what we see.    *
  182.   ***************************************************************************/
  183.  
  184.   WinSendMsg ( hwndSubMenu, MM_INSERTITEM, MPFROMP(Item), MPFROMP(Text) ) ;
  185. }
  186.  
  187. /****************************************************************************
  188.  *                                                                          *
  189.  *                           Add Item to Menu                               *
  190.  *                                                                          *
  191.  ****************************************************************************/
  192.  
  193. extern VOID AddMenuItem
  194. (
  195.   HWND hwndFrame,
  196.   USHORT MenuID,
  197.   MENUITEM *Item,
  198.   PSZ Text
  199. )
  200. {
  201.  /***************************************************************************
  202.   * Local Declarations                                                      *
  203.   ***************************************************************************/
  204.  
  205.   HWND hwndMenu ;
  206.  
  207.  /***************************************************************************
  208.   * Obtain the menu window handle.                                          *
  209.   ***************************************************************************/
  210.  
  211.   hwndMenu = WinWindowFromID ( hwndFrame, MenuID ) ;
  212.  
  213.  /***************************************************************************
  214.   * Add the new item to the menu.                                           *
  215.   ***************************************************************************/
  216.  
  217.   WinSendMsg ( hwndMenu, MM_INSERTITEM, MPFROMP(Item), MPFROMP(Text) ) ;
  218. }
  219.  
  220. /****************************************************************************
  221.  *                                                                          *
  222.  *                        Add Item to SubMenu                               *
  223.  *                                                                          *
  224.  ****************************************************************************/
  225.  
  226. extern VOID AddSubMenuItem
  227. (
  228.   HWND hwndFrame,
  229.   USHORT MenuID,
  230.   USHORT SubMenuID,
  231.   MENUITEM *Item,
  232.   PSZ Text
  233. )
  234. {
  235.  /***************************************************************************
  236.   * Local Declarations                                                      *
  237.   ***************************************************************************/
  238.  
  239.   HWND hwndMenu ;
  240.   HWND hwndSubMenu ;
  241.   MENUITEM MenuItem ;
  242.  
  243.  /***************************************************************************
  244.   * Obtain the menu window handle.                                          *
  245.   ***************************************************************************/
  246.  
  247.   hwndMenu = WinWindowFromID ( hwndFrame, MenuID ) ;
  248.  
  249.  /***************************************************************************
  250.   * Obtain the submenu window handle.                                       *
  251.   ***************************************************************************/
  252.  
  253.   WinSendMsg ( hwndMenu, MM_QUERYITEM,
  254.     MPFROM2SHORT ( SubMenuID, TRUE ),
  255.     (MPARAM) &MenuItem ) ;
  256.  
  257.   hwndSubMenu = MenuItem.hwndSubMenu ;
  258.  
  259.  /***************************************************************************
  260.   * Add the new item to the menu.                                           *
  261.   ***************************************************************************/
  262.  
  263.   WinSendMsg ( hwndSubMenu, MM_INSERTITEM, MPFROMP(Item), MPFROMP(Text) ) ;
  264. }
  265.  
  266. /****************************************************************************
  267.  *                                        *
  268.  *             Remove Item from SubMenu                *
  269.  *                                        *
  270.  ****************************************************************************/
  271.  
  272. extern VOID RemoveSubMenuItem
  273. (
  274.   HWND hwndFrame,
  275.   USHORT MenuID,
  276.   USHORT SubMenuID,
  277.   USHORT ItemID
  278. )
  279. {
  280.  /***************************************************************************
  281.   * Local Declarations                                *
  282.   ***************************************************************************/
  283.  
  284.   HWND hwndMenu ;
  285.   HWND hwndSubMenu ;
  286.   MENUITEM MenuItem ;
  287.  
  288.  /***************************************************************************
  289.   * Obtain the menu window handle.                        *
  290.   ***************************************************************************/
  291.  
  292.   hwndMenu = WinWindowFromID ( hwndFrame, MenuID ) ;
  293.  
  294.  /***************************************************************************
  295.   * Obtain the submenu window handle.                        *
  296.   ***************************************************************************/
  297.  
  298.   WinSendMsg ( hwndMenu, MM_QUERYITEM,
  299.     MPFROM2SHORT ( SubMenuID, TRUE ),
  300.     (MPARAM) &MenuItem ) ;
  301.  
  302.   hwndSubMenu = MenuItem.hwndSubMenu ;
  303.  
  304.  /***************************************************************************
  305.   * Remove the item from the menu.                        *
  306.   ***************************************************************************/
  307.  
  308.   WinSendMsg ( hwndSubMenu, MM_REMOVEITEM, MPFROM2SHORT(ItemID,TRUE), 0 ) ;
  309. }
  310.  
  311. /****************************************************************************
  312.  *                                                                          *
  313.  *      Enable/Disable menu item.                                           *
  314.  *                                                                          *
  315.  ****************************************************************************/
  316.  
  317. extern VOID EnableMenuItem ( HWND hwndFrame, USHORT MenuID, USHORT ItemID, BOOL Enable )
  318. {
  319.  /***************************************************************************
  320.   * Local Declarations                                                      *
  321.   ***************************************************************************/
  322.  
  323.   HWND hwndMenu ;
  324.  
  325.  /***************************************************************************
  326.   * Get the menu's window handle.                                           *
  327.   ***************************************************************************/
  328.  
  329.   hwndMenu = WinWindowFromID ( hwndFrame, MenuID ) ;
  330.  
  331.  /***************************************************************************
  332.   * Set the menu item's enable/disable status.                              *
  333.   ***************************************************************************/
  334.  
  335.   WinSendMsg ( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT ( ItemID, TRUE ),
  336.     MPFROM2SHORT ( MIA_DISABLED, Enable ? 0 : MIA_DISABLED ) ) ;
  337. }
  338.  
  339. /****************************************************************************
  340.  *                                                                          *
  341.  *      Check/Uncheck menu item.                                            *
  342.  *                                                                          *
  343.  ****************************************************************************/
  344.  
  345. extern VOID CheckMenuItem ( HWND hwndFrame, USHORT MenuID, USHORT ItemID, BOOL Enable )
  346. {
  347.  /***************************************************************************
  348.   * Local Declarations                                                      *
  349.   ***************************************************************************/
  350.  
  351.   HWND hwndMenu ;
  352.  
  353.  /***************************************************************************
  354.   * Get the menu's window handle.                                           *
  355.   ***************************************************************************/
  356.  
  357.   hwndMenu = WinWindowFromID ( hwndFrame, MenuID ) ;
  358.  
  359.  /***************************************************************************
  360.   * Set the menu item's enable/disable status.                              *
  361.   ***************************************************************************/
  362.  
  363.   WinSendMsg ( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT ( ItemID, TRUE ),
  364.     MPFROM2SHORT ( MIA_CHECKED, Enable ? MIA_CHECKED : 0 ) ) ;
  365. }
  366.  
  367. /****************************************************************************
  368.  *                                                                          *
  369.  *                        Add Program to Task List                          *
  370.  *                                                                          *
  371.  ****************************************************************************/
  372.  
  373. extern VOID Add2TaskList ( HWND hwnd, PSZ Name )
  374. {
  375.  /***************************************************************************
  376.   * Get the window's process ID.                                            *
  377.   ***************************************************************************/
  378.  
  379.   PID pid ;
  380.   WinQueryWindowProcess ( hwnd, &pid, NULL ) ;
  381.  
  382.  /***************************************************************************
  383.   * Add an entry to the system task list.                                   *
  384.   ***************************************************************************/
  385.  
  386.   SWCNTRL swctl ;
  387.   swctl.hwnd = hwnd ;
  388.   swctl.hwndIcon = NULL ;
  389.   swctl.hprog = NULL ;
  390.   swctl.idProcess = pid ;
  391.   swctl.idSession = 0 ;
  392.   swctl.uchVisibility = SWL_VISIBLE ;
  393.   swctl.fbJump = SWL_JUMPABLE ;
  394.   strcpy ( swctl.szSwtitle, (PCHAR)Name ) ;
  395.  
  396.   WinAddSwitchEntry ( &swctl ) ;
  397. }
  398.  
  399. /****************************************************************************
  400.  *                                        *
  401.  *  Build Presentation Parameters                        *
  402.  *                                        *
  403.  ****************************************************************************/
  404.  
  405. extern PPRESPARAMS BuildPresParams
  406. (
  407.   USHORT ParmCount,
  408.   PULONG Ids,
  409.   PULONG ByteCounts,
  410.   PBYTE *Parms
  411. )
  412. {
  413.  /***************************************************************************
  414.   * Determine final size of presentation parameter block.            *
  415.   ***************************************************************************/
  416.  
  417.   ULONG Size = sizeof(ULONG) ;
  418.  
  419.   for ( USHORT i=0; i<ParmCount; i++ )
  420.   {
  421.     Size += sizeof(ULONG) ;
  422.     Size += sizeof(ULONG) ;
  423.     Size += ByteCounts[i] ;
  424.   }
  425.  
  426.  /***************************************************************************
  427.   * Allocate memory for block.    Return if unable to do so.            *
  428.   ***************************************************************************/
  429.  
  430.   PPRESPARAMS PresParams = PPRESPARAMS ( AllocateMemory ( (USHORT) Size ) ) ;
  431.  
  432.   if ( PresParams == NULL )
  433.     return ( NULL ) ;
  434.  
  435.  /***************************************************************************
  436.   * Initialize the block header.                        *
  437.   ***************************************************************************/
  438.  
  439.   PresParams->cb = Size - sizeof(PresParams->cb) ;
  440.  
  441.  /***************************************************************************
  442.   * Load the presentation parameters into the block.                *
  443.   ***************************************************************************/
  444.  
  445.   PPARAM Param = PresParams->aparam ;
  446.  
  447.   for ( i=0; i<ParmCount; i++ )
  448.   {
  449.     Param->id = Ids[i] ;
  450.     Param->cb = ByteCounts[i] ;
  451.     memcpy ( Param->ab, Parms[i], (USHORT)ByteCounts[i] ) ;
  452.     PBYTE p = PBYTE ( Param ) ;
  453.     p += sizeof(Param->id) ;
  454.     p += sizeof(Param->cb) ;
  455.     p += ByteCounts[i] ;
  456.     Param = PPARAM ( p ) ;
  457.   }
  458.  
  459.  /***************************************************************************
  460.   * Return the pointer to the block.  It will need freeing by the caller.   *
  461.   ***************************************************************************/
  462.  
  463.   return ( PresParams ) ;
  464. }
  465.  
  466. /****************************************************************************
  467.  *                                        *
  468.  *    Build Extended Attributes                        *
  469.  *                                        *
  470.  ****************************************************************************/
  471.  
  472. extern PEAOP BuildExtendedAttributes ( USHORT Count, EADATA Table[] )
  473. {
  474.  /***************************************************************************
  475.   * Find out how much memory will be needed for the block.            *
  476.   ***************************************************************************/
  477.  
  478.   ULONG cbEA = sizeof(FEALIST) - sizeof(FEA) ;
  479.  
  480.   for ( int i=0; i<Count; i++ )
  481.   {
  482.     cbEA += BuildExtendedAttributeItem ( NULL, &Table[i] ) ;
  483.   }
  484.  
  485.  /***************************************************************************
  486.   * Allocate memory for the FEA list.                        *
  487.   ***************************************************************************/
  488.  
  489.   PFEALIST pFEAList = PFEALIST ( AllocateMemory ( cbEA ) ) ;
  490.  
  491.   if ( pFEAList == NULL )
  492.   {
  493.     return ( NULL ) ;
  494.   }
  495.  
  496.  /***************************************************************************
  497.   * Construct the extended attributes.                        *
  498.   ***************************************************************************/
  499.  
  500.   PFEA pFEA = pFEAList->list ;
  501.  
  502.   for ( i=0; i<Count; i++ )
  503.   {
  504.     PBYTE p = PBYTE ( pFEA ) ;
  505.     p += BuildExtendedAttributeItem ( pFEA, &Table[i] ) ;
  506.     pFEA = PFEA ( p ) ;
  507.   }
  508.  
  509.   pFEAList->cbList = PBYTE(pFEA) - PBYTE(pFEAList) ;
  510.  
  511.  /***************************************************************************
  512.   * Allocate memory for the EA header block.                    *
  513.   ***************************************************************************/
  514.  
  515.   PEAOP pExtendedAttributes = PEAOP ( AllocateMemory ( sizeof(EAOP) ) ) ;
  516.  
  517.   if ( pExtendedAttributes == NULL )
  518.   {
  519.     FreeMemory ( pFEAList ) ;
  520.     return ( NULL ) ;
  521.   }
  522.  
  523.  /***************************************************************************
  524.   * Fill in the extended attribute header block and return its address.     *
  525.   ***************************************************************************/
  526.  
  527.   pExtendedAttributes->fpGEAList = NULL ;
  528.   pExtendedAttributes->fpFEAList = pFEAList ;
  529.   pExtendedAttributes->oError = 0 ;
  530.  
  531.   return ( pExtendedAttributes ) ;
  532. }
  533.  
  534. /****************************************************************************
  535.  *                                        *
  536.  *    Build Extended Attribute Item                        *
  537.  *                                        *
  538.  ****************************************************************************/
  539.  
  540. static ULONG BuildExtendedAttributeItem ( PFEA pFEA, PEADATA Item )
  541. {
  542.  /***************************************************************************
  543.   * Store header.                                *
  544.   ***************************************************************************/
  545.  
  546.   PBYTE p = PBYTE ( pFEA ) ;
  547.  
  548.   if ( pFEA )
  549.   {
  550.     pFEA->fEA = 0 ;
  551.     pFEA->cbName = (BYTE) strlen ( (PCHAR)Item->Name ) ;
  552.     pFEA->cbValue = Item->Length + 2 * sizeof(USHORT) ;
  553.   }
  554.  
  555.   p += sizeof(FEA) ;
  556.  
  557.  /***************************************************************************
  558.   * Store name.                                 *
  559.   ***************************************************************************/
  560.  
  561.   if ( pFEA )
  562.   {
  563.     strcpy ( (PCHAR)p, (PCHAR)Item->Name ) ;
  564.   }
  565.  
  566.   p += strlen ( (PCHAR)Item->Name ) + 1 ;
  567.  
  568.  /***************************************************************************
  569.   * Store value's type.                                                     *
  570.   ***************************************************************************/
  571.  
  572.   PSHORT ps = PSHORT ( p ) ;
  573.  
  574.   if ( pFEA )
  575.   {
  576.     *ps = Item->Type ;
  577.   }
  578.  
  579.   ps ++ ;
  580.  
  581.  /***************************************************************************
  582.   * Store value's length.                                                   *
  583.   ***************************************************************************/
  584.  
  585.   if ( pFEA )
  586.   {
  587.     *ps = Item->Length ;
  588.   }
  589.  
  590.   ps ++ ;
  591.  
  592.  /***************************************************************************
  593.   * Store value.                                *
  594.   ***************************************************************************/
  595.  
  596.   p = (PBYTE) ps ;
  597.  
  598.   if ( pFEA )
  599.   {
  600.     memcpy ( p, Item->Value, Item->Length ) ;
  601.   }
  602.  
  603.   p += Item->Length ;
  604.  
  605.  /***************************************************************************
  606.   * Return count of bytes needed for item.                    *
  607.   ***************************************************************************/
  608.  
  609.   return ( p - PBYTE(pFEA) ) ;
  610. }
  611.  
  612. /****************************************************************************
  613.  *                                        *
  614.  *    Build Multi-Value Multi-Type EA Item's Value                        *
  615.  *                                        *
  616.  ****************************************************************************/
  617.  
  618. extern ULONG BuildMVMTValue ( PVOID Value, USHORT Count, MVMT_VALUE Table[] )
  619. {
  620.  /***************************************************************************
  621.   * Store the number of values.                         *
  622.   ***************************************************************************/
  623.  
  624.   PBYTE p = PBYTE(Value) ;
  625.  
  626.   if ( Value )
  627.     *PUSHORT(p) = Count ;
  628.  
  629.   p += sizeof(Count) ;
  630.  
  631.  /***************************************************************************
  632.   * Store the multiple values.                            *
  633.   ***************************************************************************/
  634.  
  635.   for ( int i=0; i<Count; i++ )
  636.   {
  637.     if ( Value )
  638.       *PUSHORT(p) = Table[i].Type ;
  639.  
  640.     p += sizeof(Table[i].Type) ;
  641.  
  642.     if ( Value )
  643.       *PUSHORT(p) = Table[i].Length ;
  644.  
  645.     p += sizeof(Table[i].Length) ;
  646.  
  647.     if ( Value )
  648.       memcpy ( p, Table[i].Value, Table[i].Length ) ;
  649.  
  650.     p += Table[i].Length ;
  651.   }
  652.  
  653.  /***************************************************************************
  654.   * Return the total byte count.                        *
  655.   ***************************************************************************/
  656.  
  657.   return ( p - PBYTE(Value) ) ;
  658. }
  659.  
  660. /****************************************************************************
  661.  *                                                                          *
  662.  *      Process Exit menu command.                                          *
  663.  *                                                                          *
  664.  ****************************************************************************/
  665.  
  666. extern MRESULT APIENTRY Exit
  667. (
  668.   HWND hwnd,
  669.   USHORT msg,
  670.   MPARAM mp1,
  671.   MPARAM mp2
  672. )
  673. {
  674.  /***************************************************************************
  675.   * Send a WM_CLOSE message to the window.                                  *
  676.   ***************************************************************************/
  677.  
  678.   WinSendMsg ( hwnd, WM_CLOSE, 0L, 0L ) ;
  679.  
  680.  /***************************************************************************
  681.   * Done.                                                                   *
  682.   ***************************************************************************/
  683.  
  684.   return ( MRFROMSHORT ( 0 ) ) ;
  685. }
  686.  
  687. /****************************************************************************
  688.  *                                                                          *
  689.  *      Process Help For Help menu command.                                 *
  690.  *                                                                          *
  691.  ****************************************************************************/
  692.  
  693. extern MRESULT APIENTRY HelpForHelp
  694. (
  695.   HWND hwnd,
  696.   USHORT msg,
  697.   MPARAM mp1,
  698.   MPARAM mp2
  699. )
  700. {
  701.  /***************************************************************************
  702.   * Get the help instance window handle, if any.                            *
  703.   ***************************************************************************/
  704.  
  705.   HWND hwndHelp = WinQueryHelpInstance ( hwnd ) ;
  706.  
  707.  /***************************************************************************
  708.   * If help is available, pass the request on to the help window.           *
  709.   ***************************************************************************/
  710.  
  711.   if ( hwndHelp )
  712.   {
  713.     WinSendMsg ( hwndHelp, HM_DISPLAY_HELP, 0L, 0L ) ;
  714.   }
  715.  
  716.  /***************************************************************************
  717.   * Done.                                                                   *
  718.   ***************************************************************************/
  719.  
  720.   return ( MRFROMSHORT ( 0 ) ) ;
  721. }
  722.  
  723. /****************************************************************************
  724.  *                                                                          *
  725.  *      Process Extended Help menu command.                                 *
  726.  *                                                                          *
  727.  ****************************************************************************/
  728.  
  729. extern MRESULT APIENTRY ExtendedHelp
  730. (
  731.   HWND hwnd,
  732.   USHORT msg,
  733.   MPARAM mp1,
  734.   MPARAM mp2
  735. )
  736. {
  737.  /***************************************************************************
  738.   * Get the help instance window handle, if any.                            *
  739.   ***************************************************************************/
  740.  
  741.   HWND hwndHelp = WinQueryHelpInstance ( hwnd ) ;
  742.  
  743.  /***************************************************************************
  744.   * If help is available, pass the request on to the help window.           *
  745.   ***************************************************************************/
  746.  
  747.   if ( hwndHelp )
  748.   {
  749.     WinSendMsg ( hwndHelp, HM_EXT_HELP, 0L, 0L ) ;
  750.   }
  751.  
  752.  /***************************************************************************
  753.   * Done.                                                                   *
  754.   ***************************************************************************/
  755.  
  756.   return ( MRFROMSHORT ( 0 ) ) ;
  757. }
  758.  
  759. /****************************************************************************
  760.  *                                                                          *
  761.  *      Process Keys Help menu command.                                     *
  762.  *                                                                          *
  763.  ****************************************************************************/
  764.  
  765. extern MRESULT APIENTRY KeysHelp
  766. (
  767.   HWND hwnd,
  768.   USHORT msg,
  769.   MPARAM mp1,
  770.   MPARAM mp2
  771. )
  772. {
  773.  /***************************************************************************
  774.   * Get the help instance window handle, if any.                            *
  775.   ***************************************************************************/
  776.  
  777.   HWND hwndHelp = WinQueryHelpInstance ( hwnd ) ;
  778.  
  779.  /***************************************************************************
  780.   * If help is available, pass the request on to the help window.           *
  781.   ***************************************************************************/
  782.  
  783.   if ( hwndHelp )
  784.   {
  785.     WinSendMsg ( hwndHelp, HM_KEYS_HELP, 0L, 0L ) ;
  786.   }
  787.  
  788.  /***************************************************************************
  789.   * Done.                                                                   *
  790.   ***************************************************************************/
  791.  
  792.   return ( MRFROMSHORT ( 0 ) ) ;
  793. }
  794.  
  795. /****************************************************************************
  796.  *                                                                          *
  797.  *      Process Help Index menu command.                                    *
  798.  *                                                                          *
  799.  ****************************************************************************/
  800.  
  801. extern MRESULT APIENTRY HelpIndex
  802. (
  803.   HWND hwnd,
  804.   USHORT msg,
  805.   MPARAM mp1,
  806.   MPARAM mp2
  807. )
  808. {
  809.  /***************************************************************************
  810.   * Get the help instance window handle, if any.                            *
  811.   ***************************************************************************/
  812.  
  813.   HWND hwndHelp = WinQueryHelpInstance ( hwnd ) ;
  814.  
  815.  /***************************************************************************
  816.   * If help is available, pass the request on to the help window.           *
  817.   ***************************************************************************/
  818.  
  819.   if ( hwndHelp )
  820.   {
  821.     WinSendMsg ( hwndHelp, HM_HELP_INDEX, 0L, 0L ) ;
  822.   }
  823.  
  824.  /***************************************************************************
  825.   * Done.                                                                   *
  826.   ***************************************************************************/
  827.  
  828.   return ( MRFROMSHORT ( 0 ) ) ;
  829. }
  830.